package com.huawei.hwid.core.a;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.Bundle;
import com.huawei.hms.aaid.constant.AaidIdConstant;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.huawei.hwid.api.common.o;
import com.huawei.hwid.c.a;
import com.huawei.hwid.core.constants.HwAccountConstants;
import com.huawei.hwid.core.d.b.e;
import com.huawei.hwid.core.d.m;
import com.huawei.hwid.core.d.n;
import com.huawei.hwid.core.datatype.HwAccount;
import com.huawei.hwid.core.encrypt.AES128_ECB;
import com.huawei.hwid.core.encrypt.Hex;
import java.security.MessageDigest;

public class b {
    private String a;
    private String b;
    private String c;
    private String d;
    private String e = "";
    private String f;
    private String g;
    private String h;
    private String i;
    private int j = 0;
    private int k;
    private String l;
    private String m;
    private String n;
    private String o;

    public b(Bundle bundle, Context context) {
        this.f = a(context);
        this.h = b(context);
        this.k = 0;
        this.l = n.a();
        this.m = context.getPackageName();
        this.n = com.huawei.hwid.core.d.b.b();
        if (com.huawei.hwid.core.d.b.a(context)) {
            this.d = com.huawei.hwid.core.d.b.b(context);
        }
        this.a = bundle.getString(HwAccountConstants.EXTRA_OPLOG_OPID);
        this.b = bundle.getString(HwAccountConstants.EXTRA_OPLOG_REQTIME);
        this.c = bundle.getString(HwAccountConstants.EXTRA_OPLOG_RSPTIME);
        this.i = bundle.getString(HwAccountConstants.EXTRA_OPLOG_OPDETAIL);
        this.o = bundle.getString("url");
        this.g = bundle.getString(HwAccountConstants.EXTRA_OPLOG_ERROR);
        this.j = bundle.getInt(HwAccountConstants.EXTRA_OPLOG_SITEID, 0);
    }

    private String a(Context context) {
        String l = com.huawei.hwid.core.d.b.l(context);
        HwAccount a = a.a(context).a(context, o.a(context), l);
        if (a != null) {
            return a.d();
        }
        return "";
    }

    private String b(Context context) {
        String str = "";
        str = n.a(context);
        try {
            ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), DnsConfig.MAX_CACHE_ENTRIES);
            if (applicationInfo.metaData == null || applicationInfo.metaData.getInt("oplog_encrypt") != 1) {
                return str;
            }
            byte[] digest = MessageDigest.getInstance(AaidIdConstant.SIGNATURE_SHA256).digest((str + new StringBuffer().append(HwAccountConstants.ENCODE_KEY_STR).append(AES128_ECB.PART_KEY_CODE_KEY).append(Hex.PART_KEY_CODE).append(m.d("mgsI")).toString()).getBytes("UTF-8"));
            StringBuffer stringBuffer = new StringBuffer();
            for (byte b : digest) {
                String toHexString = Integer.toHexString(b & 255);
                if (toHexString.length() == 1) {
                    stringBuffer.append("0");
                }
                stringBuffer.append(toHexString);
            }
            return stringBuffer.toString();
        } catch (RuntimeException e) {
            str = "";
            e.d("OpLogItem", "RuntimeException", true);
            return str;
        } catch (Exception e2) {
            str = "";
            e.d("OpLogItem", "Exception", true);
            return str;
        } catch (Error e3) {
            str = "";
            e.d("OpLogItem", "Error", true);
            return str;
        }
    }

    public int a() {
        return this.j;
    }

    public String toString() {
        StringBuilder stringBuilder = new StringBuilder("");
        stringBuilder.append(this.a).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(this.b).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(this.c).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(this.d).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(this.e).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(m.e(this.f)).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(this.g).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(this.h).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(this.i).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(this.k).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(this.l).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(this.m).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(this.o).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(this.n).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(this.j).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
        return stringBuilder.toString();
    }
}
